import Vue from 'vue'
import Ready from './ready.vue'

import router from './ready.router'
import axios from './../../http'

import 'element-ui/lib/theme-chalk/index.css';

import ElementUI from 'element-ui';
import utils from '../../utils/utils';
import { cheeToken } from '../../utils/cheToken';

Vue.use(ElementUI);
Vue.config.productionTip = false
//这样可以在各个组件中使用axios
Vue.prototype.$axios = axios;
//console.log(utils.getCookie('monitor_count'))
//查检token是否有效
const checToken = cheeToken();


checToken.then(data => {

  if (data == "ok") {
    //if (window.location.href.indexOf('?') != -1) {
      //window.location.href= utils.delUrlParams(window.location.href);
    //}
    //new Vue({
     // router,
     // render: h => h(Ready)
    //}).$mount('#ready')
    //跑到首页
    //window.location.href=document.location.protocol+"//"+window.location.host
    //window.location.href = utils.delUrlParams(window.location.href);
    var hasRePath=null;
    if(hasRePath=utils.getUrlKey("redirect")){
      if(hasRePath.indexOf('ready') != -1){
        window.location.href= '/';
      }else{
        window.location.href= hasRePath;
      }
      
    }else{
      //跳到首页
      window.location.href= '/';
    }
  } else if(data == "service_error"){
    window.location.href="/error"
  }else {
    //window.location.href = "http://www.sso.com/login?redirect=" + utils.delUrlParams(window.location.href);
    window.location.href = "http://www.sso.com/login";
  }

})

